/*
 * @Author: zhangdong 354266323@qq.com
 * @Date: 2022-06-07 16:56:53
 * @LastEditors: zhangdong 354266323@qq.com
 * @LastEditTime: 2022-06-17 09:30:28
 * @FilePath: \logistics-sunshine-unattended-app\main.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import App from './App'
import httpInterceptor from '@/common/http.interceptor.js'
//引入vuex
import store from './store'
import util from './common/util'
//把vuex定义成全局组件
const msg = (title, duration = 2500, mask = false, icon = 'none') => {
  //统一提示方便全局修改
  if (Boolean(title) === false) {
    return;
  }
  uni.showToast({
    title,
    duration,
    mask,
    icon,
  });
}
const json = type => {
  //模拟异步请求数据
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(Json[type]);
    }, 500)
  })
}

const prePage = () => {
  let pages = getCurrentPages();
  let prePage = pages[pages.length - 2];
  // #ifdef H5
  return prePage;
  // #endif
  return prePage.$vm;
}


Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$store = store;
Vue.prototype.$api = { msg, json, prePage };
Vue.prototype.$util = util;


Vue.config.productionTip = false

App.mpType = 'app'

// 引入全局uView
import uView from 'uview-ui'
Vue.use(uView);

const app = new Vue({
  ...App,
  store
})


// 引入配置的请求拦截器

// 这里需要写在最后，是为了等Vue创建对象完成，引入"app"对象(也即页面的"this"实例)
Vue.use(httpInterceptor, app)

app.$mount()
